package com.thor.palmmall.rest.order;

import org.springframework.beans.factory.annotation.Autowired;

import com.thor.commons.exception.ThorServiceException;
import com.thor.commons.query.QueryResult;
import com.thor.palmmall.rest.order.converter.AProductConverter;
import com.thor.palmmall.rest.order.converter.SProductConditionConverter;
import com.thor.palmmall.spi.common.SQueryResult;
import com.thor.palmmall.spi.common.SQueryResultConverter;
import com.thor.palmmall.spi.common.SResponse;
import com.thor.palmmall.spi.order.SProduct;
import com.thor.palmmall.spi.order.SProductService;

public class AProductServiceImpl implements AProductService {
	 @Autowired
	  private SProductService sProductService ;
	@Override
	public QueryResult<AProduct> getProducts(AProductCondition condition)
			throws ThorServiceException {
		SResponse<SQueryResult<SProduct>> resp = sProductService.getProducts(SProductConditionConverter.getInstance().convert(condition));
		 if (resp.isSuccess()){
		      return SQueryResultConverter.convert(resp.getBody(),AProductConverter.getInstance());
		 }  else{
		      throw new ThorServiceException("无法查询到商品：" + resp.getMessage());
		 }
	}
	
	
}
